package com.sloan.community.common.res;

import lombok.Data;

@Data
public class Result <T>{

    private Integer code;

    private String msg;

    private T data;

    private Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success(T data){
        return new Result<>(200,"成功",data);
    }

    public static <T> Result<T> onLine(){
        return new Result<>(505,"当前用户不在线",null);
    }

    public static <T> Result<T> success(){
        return success(null);
    }

    public static <T> Result<T> error( String msg){
        return new Result<>(500,msg,null);
    }

    public static <T> Result<T> access(){
        return new Result<>(401,"用户未登录!请先登录",null);
    }
}
